#ifndef QQTDATAMANAGER_H
#define QQTDATAMANAGER_H

#include <QObject>

#include <qqtudpclient.h>

#include <qqtdataprotocol.h>
#include <qqtframe.h>

#include <qqthighgrade_global.h>
/**
 * @brief The QQtDataManager class
 * UDP 接收、发送数据的工具。
 *
 * QQtDataSerialization - ::
 * QQtDataSerialization - ::
 */
class QQTHIGHGRADESHARED_EXPORT QQtDataManager : public QObject
{
    Q_OBJECT

public:
    explicit QQtDataManager ( QObject* parent = 0 );
    virtual ~QQtDataManager();

    //设置Server的地址、监听端口。
    void setServerAddress ( QHostAddress address, int port = 4416 );

    //设置Server的监听端口，地址为广播。
    void setServerPort ( int port = 4416 );

    //设置FindServer，也就是本地的发送、接收数据的端口。
    void setLocalAddress ( QHostAddress address, int port );

    void setLocalPort ( int port );

    //必须在设置local地址、端口之后调用才有用。
    void setSendBufferSize ( int size = 4096 );
    int getSendBufferSize();
    void setRecvBufferSize ( int size = 131072 );
    int getRecvBufferSize();

    QQtUdpClient* clientHandler();
    QQtDataProtocol* protocolHandler();

    virtual void sendMessage ( const QQtDataSerialization& data );

signals:
    void readyRead ( const QQtDataSerialization& data );

protected:

private:
    QQtUdpClient* c0;
    QQtDataProtocol* p0;
};


#endif // QQTDATAMANAGER_H

